<template>
  <div class="elm-edit">
    <elm-page-bb>
      <el-form ref="model" :model="model" size="small" label-width="80px">
        <elm-row>
          <el-form-item label="线索号" prop="ly">
            <el-input v-model="model.sys_code_key" disabled placeholder="自动生成无需填写"></el-input>
          </el-form-item>
          <el-form-item label="优先级" prop="dj">
            <elm-code dict_type="crm_lead_dj" v-model="model.dj"></elm-code>
          </el-form-item>
        </elm-row>
        <elm-row v-if="!is_turn">
          <el-form-item label="客户名称" prop="kh_name">
            <elm-cus v-model="model.kh_name"></elm-cus>
          </el-form-item>
          <el-form-item label="状态" prop="zt">
            <elm-code dict_type="crm_lead_zt" v-model="model.zt"></elm-code>
          </el-form-item>
        </elm-row>
        <el-form-item label="地址" prop="kh_dz">
          <el-input  type="textarea" :rows="2" v-model="model.kh_dz"></el-input>
        </el-form-item>
        <elm-row v-if="!is_turn">
        <el-form-item label="跟进人" prop="fzxs">
          <elm-ei v-model="model.fzxs"></elm-ei>
        </el-form-item>
          <el-form-item label="线索来源" prop="ly">
            <el-input v-model="model.ly"></el-input>
          </el-form-item>
        </elm-row>
        <el-form-item label="需求描述" prop="xqms" v-if="!is_turn">
          <el-input  type="textarea" :rows="2" v-model="model.xqms"></el-input>
        </el-form-item>
        <el-form-item label="机会分析" prop="jhfx">
          <el-input  type="textarea" :rows="2" v-model="model.jhfx"></el-input>
        </el-form-item>
        <el-form-item label="资料">
          <elm-upload module_name="biz_crm_lead_file" :rel_id="model.id" :multiple="true" :limit="10"  list-type="picture" tip=" "></elm-upload>
        </el-form-item>
        <el-form-item label="备注" prop="remark" v-if="!is_turn">
          <el-input type="textarea" :rows="2" v-model="model.remark"></el-input>
        </el-form-item>
      </el-form>
      <el-card style="min-height: 140px;"  shadow="hover" v-if="!is_turn">
        <div slot="header">
          <span>联系人信息</span>
        </div>
        <el-form ref="model" :model="model" size="small" label-width="80px">
          <elm-row>
            <el-form-item label="姓名" prop="lxr_xm">
              <el-input v-model="model.lxr_xm"></el-input>
            </el-form-item>
            <el-form-item label="职务" prop="lxr_zw">
              <el-input v-model="model.lxr_zw"></el-input>
            </el-form-item>
          </elm-row>
          <elm-row>
            <el-form-item label="电话" prop="lxr_dh">
              <el-input v-model="model.lxr_dh"></el-input>
            </el-form-item>
            <el-form-item label="邮箱" prop="lxr_email">
              <el-input v-model="model.lxr_email"></el-input>
            </el-form-item>
          </elm-row>
        </el-form>
      </el-card>
      <template #bottom>
        <el-button type="success" size="small" @click="submit">立即保存</el-button>
        <el-button size="small" @click="close">取消</el-button>
      </template>
    </elm-page-bb>
  </div>
</template>

<script>
export default {
  extends: elmVueBase,
  data() {
    return {
      is_turn:elm.dialog.request.is_turn,
      model: {id: elm.newGuid()},
    }
  },
  async created() {
  },
  methods: {
    async submit() {
      await this.$refs["model"].validate();
      var res = await elm.post('/business/crm/leadoppo/lead/Upsert', this.model);
      if (res == true) {
        this.v('保存成功。')
        this.close();
        this.request.callVue.tablebinding();
      }
      else {
        this.error('保存失败，请稍后尝试。');
      }
    },
  }
}
</script>